<?php
$nocache = 'Pragma: no-cache';//不要缓存
header($nocache);
$nocache = 'Cache-Control: no-cache';//不要缓存
header($nocache);
mysql_connect('localhost','root','');
//------------------------------环境，函数，类
//print_r($_POST);
$word=trim($_POST['word']);
$tone=trim($_POST['tone']);//去空
if(empty($word)||empty($tone)){
	echo '输入为空';
	exit;
}
$sql_sentence = <<<EOBODY
	SELECT  *
	FROM `eng_strai`.`words`
	where `word`='$word' and  `yb`='$tone'
EOBODY;
$sql_result = mysql_query($sql_sentence);
$sql_error = mysql_error();//mysql错误提示
echo $sql_error;
$sql_r_n = mysql_num_rows($sql_result);
//$r = mysql_fetch_array($sql_result,MYSQL_ASSOC);
if($sql_r_n==1){
	echo $word.'='.$tone.'已经存在';
	exit;
}else{
	$sql_sentence = <<<EOBODY
	INSERT INTO `eng_strai`.`words`(`id`,`word`,`yb`,`xs`) 
	VALUES (null,'$word','$tone',default)
EOBODY;
}

//----插入修改
//echo $sql_sentence;
$sql_result = mysql_query($sql_sentence);
if($sql_result){
	echo $word.'='.$tone.'成功';
}else{
	echo $word.'='.$tone.'失败';
	echo $sql_sentence;
}
?>